﻿using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Reflection;
using System.ComponentModel;
using System.Security;
using System.Security.Permissions;

using PickGold.Arguments;

using HttpJson = PickGold.Web.Json;

namespace PickGold.Web
{
	/// <summary>
	/// Ajax 调用控件接口
	/// </summary>
	public interface IAjaxInvoker// : IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
	{
		/// <summary>
		/// Ajax调用事件
		/// </summary>
		event AjaxEventHandler Ajax;

		/// <summary>
		/// 引发Ajax调用事件
		/// </summary>
		/// <param name="parameters"></param>
		/// <returns></returns>
		bool AjaxInvoke(string[] parameters);
	}

	/// <summary>
	/// Ajax调用事件参数
	/// </summary>
	public class AjaxEventArgs : AsyncResultEventArgs
	{
		private object _Sender;
		private string[] _Parameters;

		/// <summary/>
		public AjaxEventArgs() : this(null, null) { }

		/// <summary>
		/// 使用参数构造一新实例。
		/// </summary>
		/// <param name="sender">事件发送者</param>
		/// <param name="parameters">Ajax 参数。</param>
		public AjaxEventArgs(object sender, string[] parameters) : base(-1)
		{
			this._Sender = sender;
			this._Parameters = parameters;
		}

		/// <summary>
		/// 事件发送者
		/// </summary>
		public object Sender
		{
			get
			{
				return this._Sender;
			}
		}

		/// <summary>
		/// Ajax 参数
		/// </summary>
		public string[] Parameters
		{
			get
			{
				return this._Parameters;
			}
		}
	}

	/// <summary>
	/// 表示将处理一个Ajax事件的方法。
	/// </summary>
	/// <param name="sender">事件源。</param>
	/// <param name="e">事件参数。</param>
	public delegate void AjaxEventHandler(object sender, AjaxEventArgs e);
}
